package cn.tedu.utils;/**
 * @Author 金帮嘉诚 @Date 2021-07-20 星期二 9:41
 */
/*本类用于测试*/

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

/**
 * 知识点
 */
public class MybatisUtil {
    public static SqlSession getSession() {
        InputStream inputStream;
        SqlSessionFactory sqlSessionFactory;
        SqlSession sqlSession;
        try {
            inputStream = Resources.getResourceAsStream("mybatis-config.xml");
            sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
            sqlSession = sqlSessionFactory.openSession();
            return sqlSession;
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }
}
